﻿using Estsh.Core.Model.Extend.IFModels;
using Estsh.Core.Models;
using Estsh.Core.Quartz.BaseService;
using Estsh.Core.Util;
using Estsh.Core.Wms.IRepositories;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Estsh.Core.Wms.Jobs
{
    public class QCJob:IJobService
    {
        private readonly IInterfaceMasterRepository repository;

        public QCJob(IInterfaceMasterRepository _qcRepository)
        {
            this.repository = _qcRepository;
        }

        public string ExecuteService(string parameter)
        {
            try
            {
                List<WmsToqce> toqcs = repository.GetWmsToqcs();
                if (toqcs.Count <= 0)
                {
                    return "没有质检单结果信息的数据！";
                }

                bool bl = repository.InsertQCInfo(toqcs);
                if (bl == true)
                {
                    return "质检单结果信息数据同步成功！";
                }
                else
                {
                    return "质检单结果信息数据同步失败！";
                }

            }
            catch (Exception ex)
            {
                LogHelper.Error("质检单结果信息接口错误！" + ex);
                return "质检单结果信息接口错误！" + ex.Message;
            }
        }
    }
}
